package com.link.base.base.report.controller;

import com.link.base.base.order.model.SaleOrder;
import com.link.base.base.report.model.CommonItem;
import com.link.base.base.report.service.SalesReportService;
import com.link.core.cllog.LCLogger;
import com.link.core.basic.annotations.JsonParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.*;


/**
* 销售类相关报表
* @author Lizongting
* @date 2018/12/6
*/
@Controller
@RequestMapping("/link/report")
public class SalesReportController {

    @Resource
    private SalesReportService salesReportService;

    /**
    * 产品销售额的报表统计
    * @param record
    * @author Lizongting
    * @date 2018/12/6
    */
    @RequestMapping(value = "/querySalesProduct", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> querySalesProduct(@JsonParam SaleOrder record) {
        Map<String, Object> map = new HashMap<>();
        try {
            List<CommonItem> list = salesReportService.querySalesProduct(record);
            map.put("rows",list);
            map.put("success", true);
        } catch (Exception e) {
            map.put("success", false);
            map.put("result", e.getMessage());
            LCLogger.withException(e);
        }
        return map;
    }

}
